package com.zhao.customer.controller;


import com.google.code.kaptcha.Constants;
import com.zhao.customer.dao.UserDao;
import com.zhao.customer.entity.User;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/list.do")
public class ListController extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        List<User> users = null;
        try {
            users = new UserDao().selectAll();
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println(users);
        req.getSession().setAttribute("users", users );
        resp.sendRedirect("listUser.jsp");
    }
}
